home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16108 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.3 KB

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: jsarkela@aol.com (Jsarkela)
  3. Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.java,comp.lang.sather
  4. Subject: Re: What Should An Exception Handling Do? -- Clarification of rules
  5. Date: 9 Apr 1996 12:01:29 -0400
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4ke1kp$pem@newsbf02.news.aol.com>
  9. References: <31647113.13BD8C66@cygnus.com>
  10. Reply-To: jsarkela@aol.com (Jsarkela)
  11. NNTP-Posting-Host: newsbf02.mail.aol.com
  12.  
  13. Just recently joined the thread, here is my point of view.
  14. Quoting a base definition of this thread, exceptions are...
  15.  
  16. > The definition:
  17. > >       "Exception handling is intended to allow code that has
  18. encountered
  19. > >a condition it cannot cope with to return to some other code that
  20. > >directly or indirectly invoked it. There is no way for an exception
  21. > >handler to request the thread of control to resume from the throw
  22. point.
  23. > >In other words, "throw" implements the termination model of exception
  24. > >handling."     -ARM, Ellis & Stroustrup, page 354
  25. > >
  26.  
  27. As an Eiffel and Smalltalk programmer, I find that viewing exceptions only
  28.  
  29. as, I can't cope situations, is a limited point of view. Consider
  30. contracts.
  31. A contract describes a meeting of minds between a client and a supplier.
  32. The nature of the agreement is that it is observable, verifiable and
  33. enforceable. If either party determines this agreement has been violated,
  34. then the service provider and consumer should enter arbitration to resolve
  35. the dispute. The exception handler serves as the arbitrator. Note that
  36. VisualSmalltalk models exceptions as objects allowing handlers to be
  37. associated with the call chain resolving from most recent call site to
  38. most remote, but also to associate arbitration code with the exception
  39. object itself as a default handler. (Note, many exceptions may be handled
  40. by the default handler in the exception object and resume subsequently on
  41. the thread which raised the signal.
  42.  
  43. In the case of a real "error", then resumption is almost certainly not a
  44. good idea. Resumption semantics become more compelling when an event may
  45. arise calling into question conformance with the agreement forged in the
  46. contract but which in fact is a false alarm.
  47.  
  48. Real world case in point. Imagine a fictious object runtime which must
  49. have one binary support the range of operating systems with the interface
  50. identified as Win32. Under Win32s many file operations will return an
  51. error code 87 when in fact Windows95 or Window NT will give a notification
  52. code with more meaning. on the Win32s platform an error code 87 may
  53. indicate a dire consequence or merely be an informative notification.
  54. Structuring the File System framework to use exception handlers can allow
  55. an 87 error code to raise an exception and let the arbitrator determine
  56. the settlement of the outcome. That is to say, is this a trivial
  57. notification? Or, is this a serious error condition. In the first case, we
  58. may resume. In the second, we must take direct alternative action.
  59.  
  60. Contracts are binding agreements. Binding to an operating system interface
  61. requires us to acknowledge that many implementations of the same interface
  62. may have varying degrees of robustness (and unfortunately semantic
  63. correctness). It is my experience that one collaboration model may serve
  64. as a common design for multiple host platforms. However, each platform
  65. will  raise it's own set of issues, often requiring platform specific
  66. resolution. The resolution of the exception state in this modern age might
  67. depend on platform rather than call stack state. As such, perhaps an
  68. objective view of exceptions is required. A view in which the client,
  69. supplier and exception handlers comprise the principle state of the
  70. exceptional situation and the state of the call stack at the time of
  71. exception is the history that the parties bring to the table for
  72. arbitration.
  73.  
  74. The Visual Smalltalk Team programming environment makes heavy use of
  75. exceptions not only to signal errors, but also as a notification
  76. mechanism. This is a simple and direct abstraction to use, and more
  77. closely models the programming as contracting principles.
  78.  
  79. -- John Sarkela     jsarkela@aol.com
  80. -- My views are my own and not those of employers past or present.
  81. -- Well, my jobs have profoundly imprinted a point of view.
  82.  
  83.